<template>
	<div>
		<h3>{{title}}</h3>
		<img :src="src">
		<p>{{name}}</p>
	</div>
</template>

<script>
	import {addJs} from "@/utils/index.js"
	import jQuery from 'jquery'
	export default {
		name: "qq_redirect",
		data() {
			return {
				title: "",
				src: "",
				name: ""
			}
		},
		computed: {
		},
		components: {
		},
		methods: {
		},
		mounted() {
			var _this = this;
			window.onload = function(){
			QC.Login.getMe(function(openId, accessToken) {
				var qq_user_info = {
					accessToken: accessToken,
					openId: openId
				}
				jQuery.ajax({
					url: "/qq_api/user/get_user_info",
					data: {
						access_token: accessToken,
						oauth_consumer_key: 101928598,
						openid: openId
					},
					type: "GET",
					success: function(result) {
						result = JSON.parse(result);
						console.log(result);
						_this.title = "登录成功,1秒后跳转"
						_this.src = result.figureurl_qq_1;
						_this.name = result.nickname
						var userinfo = {
							headphoto: result.figureurl_qq_1,
							username: result.nickname,
							id: openId
						}
						_this.$user.setUserInfo(userinfo);
						setTimeout(function() {
							window.location.href = '/login';
						}, 1000);
					},
				});
			})
			}
		},
		created() {
			addJs("https://connect.qq.com/qc_jssdk.js");
		},
		//页面创建之初自动触发的事件
		beforeCreate() {
		},
		beforeUpdate() {}
	}
</script>

<style>
</style>
